package com.zyh.hotel.controller;


import com.alibaba.fastjson2.JSONObject;
import com.zyh.hotel.dao.UserDao;
import com.zyh.hotel.model.User;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
@CrossOrigin(origins = "*")
public class UserController {


    @Resource
    UserDao ud;

    //登录验证
    @PostMapping("/login")
    public String Login(@RequestBody User u1)
    {
        String un = u1.getUsername();
        String pd = u1.getPassword();
        User user = ud.findByUsername(un);
        System.out.println(un);
        System.out.println(pd);
        System.out.println(u1);
        if(user!=null&&pd.equals(user.getPassword())){
            return "登录成功";
        }else{
            return "用户名或密码错误";
        }
    }

}
